<?php

define('ENV_DEV', 'dev');
define('ENV_TEST', 'test');
define('ENV_PRO', 'pro');

define('DIR_ROOT', dirname(__DIR__));

/**
 * Get the root path.
 *
 * @param  string  $path
 * @return string
 */
function root_path($path = ''): string
{
    return DIR_ROOT.trim_path($path);
}

/**
 * Get the application path.
 *
 * @param  string  $path
 * @return string
 */
function app_path($path = ''): string
{
    return root_path('app').trim_path($path);
}

/**
 * Get the bootstrap path.
 *
 * @param  string  $path
 * @return string
 */
function bootstrap_path($path = ''): string
{
    return root_path('bootstrap').trim_path($path);
}

/**
 * Get the configuration path.
 *
 * @param  string  $path
 * @return string
 */
function config_path($path = ''): string
{
    return root_path('config').trim_path($path);
}

/**
 * Get the storage path.
 *
 * @param  string  $path
 * @return string
 */
function storage_path($path = ''): string
{
    return root_path('storage').trim_path($path);
}

/**
 * Get the vendor path.
 *
 * @param  string  $path
 * @return string
 */
function vendor_path($path = ''): string
{
    return root_path('vendor').trim_path($path);
}

/**
 * Get the public path.
 *
 * @param  string  $path
 * @return string
 */
function public_path($path = ''): string
{
    return root_path('public').trim_path($path);
}

/**
 * Get the static path.
 *
 * @param  string  $path
 * @return string
 */
function static_path($path = ''): string
{
    return public_path('static').trim_path($path);
}

/**
 * Get the cache path.
 *
 * @param  string  $path
 * @return string
 */
function cache_path($path = ''): string
{
    return storage_path('cache').trim_path($path);
}

/**
 * Get the log path.
 *
 * @param  string  $path
 * @return string
 */
function log_path($path = ''): string
{
    return storage_path('log').trim_path($path);
}

/**
 * Get the tmp path.
 *
 * @param  string  $path
 * @return string
 */
function tmp_path($path = ''): string
{
    return storage_path('tmp').trim_path($path);
}

/**
 * Trim path slash
 *
 * @param  string  $path
 * @return string
 */
function trim_path(string $path): string
{
    $path = trim($path, '/');

    return $path ? "/{$path}" : '';
}

/**
 * Dump the args then exit.
 *
 * @param  array  $args
 */
function dd(...$args)
{
    foreach ($args as $arg) {
        var_dump($arg);
    }
    exit();
}